package com.jinbo.footmessage.serverInf;


import java.util.ArrayList;
import java.util.List;

import android.support.v4.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.AdapterView.OnItemClickListener;

import com.jinbo.footmessage.R;
import com.jinbo.footmessage.httpbean.ProjectBean;
import com.jinbo.footmessage.httpbean.WorkerInformationBean;
import com.jinbo.footmessage.httpretrofit.BusinessController;
import com.jinbo.footmessage.httpretrofit.Listener;

public class ProjectFragment extends Fragment /*implements ServerInfActivity.Callbacks*/{
	ListView list;
	ProjectItemListViewAdapter adapter;
	List<ProjectBean> projects;
	private View mLoadView;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) 
	{
		// TODO Auto-generated method stub
		View view= inflater.inflate(R.layout.fragment_project, container, false);
		mLoadView = view.findViewById(R.id.loading);
		list=(ListView)view.findViewById(R.id.mainListView);
		adapter=new ProjectItemListViewAdapter(getActivity(),projects);
		list.setAdapter(adapter);
		String user_id=getArguments().getString("worker_id");
		BusinessController.getInstance().getMyProjects(user_id, new Listener<WorkerInformationBean>() {
			@Override
			public void onStart(Object... params) {
				//showProgressDialog("请稍后...");
				mLoadView.setVisibility(View.VISIBLE);
			}

			@Override
			public void onComplete(WorkerInformationBean result, Object... params) {
				//dismissProgressDialog();
				mLoadView.setVisibility(View.GONE);
				projects = result.projects;
				adapter.setprojects(projects);
				adapter.notifyDataSetChanged();
				//Log.d("size",projects.size()+"");

			}

			@Override
			public void onFail(final String msg, Object... params) {
				//dismissProgressDialog();
				mLoadView.setVisibility(View.GONE);
				if (TextUtils.isEmpty(msg)) {
				} else {
					((ServerInfActivity)getActivity()).show(msg);
				}
			}
		});


		//list.setOnItemClickListener(new O);
		return view;
	}
/*
	@Override
	public void change(int number) {
		// TODO Auto-generated method stub

	}
	
	@Override
	public void menu(PopupWindow menu) {
		// TODO Auto-generated method stub
	}*/
}






